const util = require('../../utils/util.js')

Page({
  data: {
      longitude: 104.049514, // 地图中心点经度
      latitude: 30.639112,  // 地图中心点纬度
      scale: 14,             // 地图缩放级别
      markers: [
        
      ]
  },
  onLoad() {
   
  },
  onShow() {
    console.log('onshow')
    util.http('/wx/showAssets?id=' + wx.getStorageSync('id'), (resp) => {
        console.log(resp.data)
        const newMarkers = [];
        const dataArray = resp.data;
        for (let i = 0; i < dataArray.length; i++) {
            const item = dataArray[i];
            const newMarker = {
                id: i + 2, // 假设从 3 开始编号，可根据实际调整
                longitude: item.longitude,
                latitude: item.latitude,
                title: item.title || '资产位置',
                iconPath: '/images/marker.png', // 需替换为实际图标
                width: 30,
                height: 30
            };
            newMarkers.push(newMarker);
        }
        const currentMarkers = this.data.markers;
        this.setData({
            markers: currentMarkers.concat(newMarkers)
        });
    });
}
});
  